package com.xiaoqi.api.controller.admin;


import com.xiaoqi.api.dto.SchoolCenterDTO;
import com.xiaoqi.api.query.SchoolCenterQuery;
import com.xiaoqi.api.service.SchoolCenterService;
import com.xiaoqi.api.utlis.Result;
import com.xiaoqi.api.vo.SchoolCenterVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/school")
public class SchoolCenterController {

    @Resource
    private SchoolCenterService schoolCenterService;

    @ApiOperation("查询分类")
    @GetMapping
    public Result<List<SchoolCenterVO>> find(SchoolCenterQuery schoolCenterQuery){ //categoryQuery封装了查询的条件
        com.neu.api.utils.PageResult<SchoolCenterVO> page = schoolCenterService.find(schoolCenterQuery);

        return Result.ok("成功",page.getList(),page.getTotal());
    }



    @ApiOperation("添加分类")
    @PostMapping
    public Result add(SchoolCenterDTO schoolCenterDTO){
        schoolCenterService.add(schoolCenterDTO);
        return Result.ok("添加成功");
    }

}